module SortArrowsHelper
	def sort_arrows(column_header, sorted_by, dir = "normal", overwrite_opts = {})
		over_params = { :sortby => column_header, :controller => controller.controller_name }
		over_params.merge! overwrite_opts
		# down arrow
		if column_header == sorted_by and ( dir == "normal" or dir.nil? )
			down_arrow = image_tag "downon.gif", :class => "image_no_border"
		else
			over_params[:dir] = "normal" 
			down_arrow = link_to image_tag("downoff.gif", :class => "image_no_border"), 
					{ :overwrite_params => over_params }
		end
		
		#up arrow
		if column_header == sorted_by and dir == "reverse"
			up_arrow = image_tag "upon.gif", :class => "image_no_border"
		else
			over_params[:dir] = "reverse"  
			up_arrow = link_to image_tag("upoff.gif", :class => "image_no_border"), 
					{ :overwrite_params => over_params }
		end
		down_arrow + up_arrow
	end
end
